package com.pw.study.flink.demo

import org.apache.flink.api.scala._

object WordCountByBatch {
  def main(args: Array[String]): Unit = {
    //1.启动环境
    val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
    //2.输入数据
    val ds: DataSet[String] = env.readTextFile("data/file/words.txt")
    //3.处理数据
    val dsMap: DataSet[(String, Int)] = ds.flatMap(_.split(" ")).map((_,1))
    val result: AggregateDataSet[(String, Int)] = dsMap.groupBy(0).sum(1)
   // dsMap.print()
    result.print()

//    env.execute("WordCountBatch")
    //
  }


}
case class Word(word: String, one: Int)
